package com.sxpi.chapter.service;

import com.sxpi.chapter.service.vip.IUserVipService;
import com.sxpi.chapter.service.vip.NormalUserServiceImpl;
import com.sxpi.chapter.service.vip.SVipUserServiceImpl;
import com.sxpi.chapter.service.vip.VipUserServiceImpl;

/**
 * @Author: 董伟豪
 * @Date: 2022/12/31 14:20
 */
public class UserFactoryBean {

    /**
     * 通过简单工厂设计模式，完成不同身份对象的获取
     * 后续我只需要在工厂里面添加就行了
     * @param vip
     * @return
     */
    public static IUserVipService getInstance(Integer vip){
        IUserVipService vipService = null;
        if(vip.equals(1)){
            vipService = new NormalUserServiceImpl();
        }else if(vip.equals(2)){
            vipService = new VipUserServiceImpl();
        }else if(vip.equals(3)){
            vipService = new SVipUserServiceImpl();
        }
        return vipService;
    }
}
